.pragma library

String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
 if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
        return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
    } else {
        return this.replace(reallyDo, replaceWith);
    }
}
//格式化文章的内容，去掉 <![CDATA[  和 ]]>
function formatAricleContent(str) {
    str=escape(str); //用escape函数来进行编码
    str=str.replace("%3C%21%5BCDATA%5B%20%20%20%20","");//替换开头的<![CDATA[ 和相连的空格
    str =str.replace("...%5D%5D%3E","");//替换最后部分的...]]>
    str=unescape(str);//解码
    str = str.substring(0,str.length-1);// 删除最后的部分
    str = str+"...";//加上省略符号
    return str;
}

function allTrim(str){
  var ResultStr = "";
  var Temp=str.split(" ");//双引号之间是一个空格
   for(var i = 0; i < Temp.length; i++){
       if(Temp[i] && Temp[i]!==null)
          ResultStr +=Temp[i];
   }
   return ResultStr;
}
/**
 *删除左右两端的空格
 */
function trim(str){
    return str.replace(/(^\s*)|(|s*$)/g,"");
}
/**
 *删除左两端的空格
 */
function ltrim(str){
    return str.replace(/(^\s*)/g,"");
}
/**
 *删除右两端的空格
 */
function trim(str){
    return str.replace(/(|s*$)/g,"");
}
/**
  * 获取文章页面的当前页面号码
  */
function getArticleCurrentPageIndexShowText(currentUrl,totalPageSize){
    var index=currentUrl.toString().lastIndexOf("page=");
    if(index!==-1){
        var pageIndex =currentUrl.toString().substring(index+5,currentUrl.length);
        console.log("pageIndex:"+pageIndex);
        return "第"+pageIndex+"/"+totalPageSize+"页";
    }else{
        return  "第1/"+totalPageSize+"页";
    }
}
/**
 * 已知标题优化显示
 */
function getArticleName(typeId,name){
    if(typeId=="0")
        return "最新";
    else if(typeId =="1")
        return "新闻";
    else if(typeId=="2")
        return "行情";
    else if(typeId=="3")
        return "评测";
    else if(typeId=="60")
        return "导购";
    else if(typeId=="82")
        return "用车";
    else
        return name;
}

/**
 * 列表传递到文章的参数
 * 文章id, 文章页数，回复数
 */
var articleId,pageNum,replyPageNum,pageTarget;

function getReplyPageNum(){
    return replyPageNum;
}
function setReplyPageNum(num){
    replyPageNum = num;
}

function getArticleId(){
    return articleId;
}
function setArticleId(id){
    articleId =id;
}
function getPageNum(){
    return pageNum;
}
function setPageNum(num){
    pageNum =num;
}
function setPageTarget(target){
   pageTarget =target;
}
function getPageTarget(){
    return pageTarget;
}
//获取文章内容页面的url
function getContentUrl(articleId){
    return "http://sp.autohome.com.cn/Nokia/ArticlePageList.ashx?type=1&Id="+articleId;
}
//获取焦点图片的加载地址
function getFocusImageUrl(){
    return "http://sp.autohome.com.cn/Nokia/FocusPic.ashx?type=1&count=10&PhoneWidth=480";
}
var currentMenuIndex;
function getCurrentMenuIndex(){
    return currentMenuIndex;
}
function setCurrentMenuIndex(index){
    currentMenuIndex =index;
}

